package com.phpxiu.app.view.custom;

import android.annotation.TargetApi;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

/**
 * Created by WuJinZhou on 2016/1/7.
 */
@Deprecated
public class MRelativeLayout extends RelativeLayout {
    private OnITEListener onITEListener;
    public MRelativeLayout(Context context) {
        super(context);
    }

    public MRelativeLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(21)
    public MRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if(ev.getAction()==MotionEvent.ACTION_DOWN){
            if(onITEListener!=null){
                onITEListener.onEventKeyDown(ev.getX(),ev.getY());
            }
        }
        return super.onInterceptTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return super.onTouchEvent(event);
    }

    public OnITEListener getOnITEListener() {
        return onITEListener;
    }

    public void setOnITEListener(OnITEListener onITEListener) {
        this.onITEListener = onITEListener;
    }

    public interface OnITEListener{
        void onEventKeyDown(float x, float y);
    }
}
